package com.wbc.smartHome.dao;

import com.wbc.smartHome.model.CommodityLabel;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface CommodityLabelDao {

    List<CommodityLabel> getCommodityLabelList(CommodityLabel commodityLabel);

    @Insert("insert into commodity_label(name,oper_time,adminid)values (#{name},now(),#{adminid})")
    void setCommodityLabel(String name,int adminid);

    @Select("select id,name from commodity_label where id in (select labelid from commodity_clabel where commodityid = #{id})")
    List<CommodityLabel> getCommodityLabelNameByCommodityId(Integer id);

    @Select("select name from commodity_type where id = #{labelId}")
    List<CommodityLabel> getCommodityLabelNameByLabelId(Integer labelId);

    @Delete("delete from commodity_label where id = #{id}")
    void delete(int id);

    @Select("select id,name from commodity_label where id = #{id}")
    CommodityLabel getCommodityLabelById(int id);

    @Update("update commodity_label set name = #{name},adminid = #{adminId} , oper_time =now() where id = #{id}")
    void updateCommodityLabel(Integer id, String name, int adminId);
}
